home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 46 / Amiga Format CD46 (1999-10-20)(Future Publishing)(GB)[!][issue 1999-12].iso / -in_the_mag- / reader_requests / scilab / demos / control / mixed.dem < prev    next >
Text File  |  1999-09-16  |  2KB  |  55 lines

  1. exec(SCI+'/demos/control/scheme.dem');
  2. x_message(['Mixed Sensitivity Controller Design';
  3.            'file: '+SCI+'/demos/control/scheme.dem'])
  4. s=poly(0,'s');
  5. str='[(s-1)/((s-1)^2*(s+2))]';
  6. rep=x_dialog('Nominal plant?',str)
  7. if rep==[] then return,end
  8. Plant=evstr(rep);Plant=syslin('c',Plant);
  9.  //Nominal Plant
  10. P22=tf2ss(Plant);    //...in state-space form
  11. [ny,nu,nx]=size(P22);
  12. [Pms,r]=augment(P22);
  13. txt=['W1 (sensitivity function S)';'W2 (K*S)';'W3 (complementary sensitivity T)'];
  14. default=['s';'1';'1'];
  15. while %t
  16.   rep=x_mdialog('Set weighting functions',txt,default);
  17.   if rep==[] then return;end
  18.   W1=evstr(rep(1));W2=evstr(rep(2));W3=evstr(rep(3));
  19.   default=rep;
  20.   Pms=sysdiag(W1,W2,W3,eye(P22))*Pms;
  21.   gms=['gamma min= ';'gamma max= ';'# iterations'];
  22.   vals=['0.01';'1000';'50'];
  23.   reps=x_mdialog('Set interval for gamma and #iterations',gms,vals);
  24.   if reps==[] then return;end
  25.   mumin=1/evstr(reps(2))^2;
  26.   mumax=1/evstr(reps(1))^2;
  27.   iter=evstr(reps(3));
  28.   [K,mu]=h_inf(Pms,r,mumin,mumax,iter);
  29.   if K~=[] then break;end
  30. end
  31.  
  32. disp(spec(h_cl(Pms,r,K)),'closed loop eigenvalues')    //Check internal stability
  33. [Ssens,Rsens,Tsens]=sensi(P22,K);  //Sensitivity functions
  34. x_message('Singular values plot')
  35. fcts=['S function';'R (=K*S) function';'T function'];
  36. www=x_mdialog('Select sensitivity function',fcts,['Yes';'No';'Yes']);
  37. if www=[] then return,end
  38. ww1=part(www(1),1)=='Y';
  39. if ww1 then
  40. xbasc(1);xset("window",1);xselect();gainplot(Ssens);
  41. xtitle('S = Sensitivity function');
  42. end
  43.  
  44. ww2=part(www(2),1)=='Y';
  45. if ww2 then
  46. xbasc(2);xset("window",2);xselect();gainplot(Rsens);
  47. xtitle('R (=G*S) Sensitivity function');
  48. end
  49.  
  50. ww3=part(www(3),1)=='Y';
  51. if ww3 then
  52. xbasc(3);xset("window",3);xselect();gainplot(Tsens);
  53. xtitle('T = Complementary Sensitivity function');
  54. end
  55.